package com.fmi.timedealer;

import java.io.Serializable;

public class ActivityItem implements Comparable<Object>, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3539889103505564409L;
	
	private String category;
	private String description;
	private String name;
	private int id;

	public static final String ACTIVITY_ITEM = "activityItem";

	public ActivityItem(String name, String description, String category) {
		super();
		this.category = category;
		this.description = description;
		this.name = name;
	}
	
	public ActivityItem(int id, String name, String description, String category) {
		this(name, description, category);
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public String toString() {
		return getName();
	}

	public int compareTo(Object other) {

		if (this == other)
			return 0;
		
		if (!(other instanceof ActivityItem))
			return -1;
		
		String otherName = ((ActivityItem) other).getName();
		return this.getName().compareTo(otherName);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((category == null) ? 0 : category.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + id;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ActivityItem other = (ActivityItem) obj;
		if (category == null) {
			if (other.category != null)
				return false;
		} else if (!category.equals(other.category))
			return false;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (id != other.id)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
